package org.example.config;

import org.example.interceptor.AdminTokenInterceptor;
import org.example.interceptor.UserTokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
public class WebConfig implements WebMvcConfigurer{

	public void addInterceptors(InterceptorRegistry registry) {
//		管理员拦截器
		InterceptorRegistration adminInter =  registry.addInterceptor(new AdminTokenInterceptor());
		adminInter.addPathPatterns("/adminApi/**"); //都得进入拦截器
		adminInter.excludePathPatterns("/adminApi/loginCtl/login");//放行地址
		adminInter.excludePathPatterns("/Redis/redisTest");//放行地址
//      用户拦截器
		InterceptorRegistration userInter =  registry.addInterceptor(new UserTokenInterceptor());
		userInter.addPathPatterns("/userApi/**"); //都得进入拦截器
		userInter.excludePathPatterns("/userApi/loginCtl/login");//放行地址
		userInter.excludePathPatterns("/userApi/loginCtl/register");//放行地址
		userInter.excludePathPatterns("/userApi/loginCtl/uploadImg");//放行地址
		userInter.excludePathPatterns("/userApi/attractions/getDisplayImage");//放行地址
		userInter.excludePathPatterns("/userApi/attractions/info");//放行地址
		userInter.excludePathPatterns("/userApi/faqCtl/faq");//放行地址
		userInter.excludePathPatterns("/userApi/eventCtl/info");//放行地址
		userInter.excludePathPatterns("/userApi/food/info");//放行地址
		userInter.excludePathPatterns("/userApi/attractions/searchByWord");//放行地址
		userInter.excludePathPatterns("/Redis/redisTest");//放行地址
	}


}
